package com.young.springdemo.service.prototypePattern;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class TestShadowClone {

//    @PostConstruct/
    public void test() throws CloneNotSupportedException {
        WeekLog weekLog,weekLogCopy;
        weekLog = new WeekLog();
        Attachment attachment = new Attachment();
        weekLog.setAttachment(attachment);
        weekLogCopy = weekLog.clone();
        System.out.println(weekLog == weekLogCopy);//浅克隆,对象不同,基本属性不同;
        System.out.println(weekLog.getAttachment() == weekLogCopy.getAttachment());//引用属性有问题
    }

}
